package com.cloud.train.business.controller.admin;

import com.cloud.train.business.domain.Train;
import com.cloud.train.business.req.TrainCarriageQueryReq;
import com.cloud.train.business.req.TrainCarriageSaveReq;
import com.cloud.train.business.req.TrainSeatSaveReq;
import com.cloud.train.business.resp.TrainCarriageQueryResp;
import com.cloud.train.business.service.TrainCarriageService;
import com.cloud.train.common.resp.CommonResp;
import com.cloud.train.common.resp.PageResp;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/train-carriage")
public class TrainCarriageAdminController {
    @Resource
    private TrainCarriageService trainCarriageService;
    @PostMapping("/save")
    public CommonResp<Object> save(@Valid @RequestBody TrainCarriageSaveReq req){
        trainCarriageService.save(req);
        return new CommonResp<>();
    }
    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delet(@PathVariable long id){
        CommonResp<Object> delete = trainCarriageService.delete(id);
        return delete;
    }
    @GetMapping("/query-list")
    public CommonResp<PageResp<TrainCarriageQueryResp>> queryList(@Valid TrainCarriageQueryReq req) {
        PageResp<TrainCarriageQueryResp> list = trainCarriageService.queryList(req);
        return new CommonResp<>(list);
    }
}
